<template>
  <el-form-item label="onChange" label-width="150px">
    <el-button :type="editEventButtonType('onChange')" icon="el-icon-edit" plain round @click="editEventHandler('onChange', getEventParams())">
      {{i18nt('designer.setting.addEventHandler')}}</el-button>
  </el-form-item>
</template>

<script>
  import i18n from "@/utils/i18n"
  import eventMixin from "@/components/form-designer/setting-panel/property-editor/event-handler/eventMixin"

  export default {
    name: "onChange-editor",
    mixins: [i18n, eventMixin],
    props: {
      designer: Object,
      selectedWidget: Object,
      optionModel: Object,
    },
    data() {
      return {
        eventParams: ['value', 'oldValue', 'nodeValue'],
      }
    },
    mounted() {
    },
    methods: {
      getEventParams() {
        const { type } = this.selectedWidget
        if (type === 'tree-select' || type === 'select') {
          return ['value', 'oldValue', 'nodeValue']
        } else {
          return ['value', 'oldValue', 'subFormData', 'rowId']
        }
      }
    }
  }
</script>

<style scoped>
.item {
  margin-top: 10px;
  margin-right: 40px;
}
</style>
